<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    let arry = [
        {
            name:"李四",
            age:18
        }
    ]
    // 字面量创建对象 对象成键值对儿存在 属性名属性值
    let user = {
        name:"张三",
        age:18
    }
    arry.push(user);
    console.log(arry)
    // .属性名获取对象中属性值
    console.log(user.name)
    console.log(user.age)
    console.log(user['name'])
    // 改变对象中属性对应的属性值
    user.name =  '王武'
    user["age"] = 29
    console.log(user)
    
    let shop = {
        a:123,
        b:456
    }
    let {a,b} = shop;
    let name = '哈哈哈'
    let age = 20;
    let c = {
        name,
        age
    }

    // 构造函数
    function People(sex,phone){
        this.name = '张三'
        this.age  =18;
        this.sex = sex;
        this.phone = phone
        console.log(this)
    }
    People.prototype.like = '学习'
    People.prototype.say = ()=>{
        console.log("学习使我快乐")
    }
    let p = new People("男",110);
    console.log(p)
    let p1 = new People("女",120)
    console.log(p1)
    p1.say();

    //class 类 
    class Zoom {
        // name = '小花'
        age=2
        constructor(name,sex){
            console.log(this)
            this.name = name;
            this.sex = sex;
            console.log('立即执行')
        }
        // 类属性
        static like = "叫"
        eat(){
            console.log("会吃")
        }
    }
    let dog = new Zoom("小花","公");
    console.log(dog)
    let cat = new Zoom("小猫",'母');
    console.log(cat)
    console.log(Zoom.like)

    class User extends Zoom{
        constructor(name,sex){
            super(name,sex)
        }
    }
    let u = new User("小红","女")
    console.log(u)

    function aaa(){
        console.log("哈哈哈哈哈")
    }
</script>
</html>